package com.hmall.item.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.context.annotation.Configuration;

import java.util.Date;
@Configuration
public class DataConfig implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        // 设置创建时间
        this.setFieldValByName("createTime", new Date(), metaObject);
        // 设置更新时间
        this.setFieldValByName("updateTime", new Date(), metaObject);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        // 设置更新时间
        this.setFieldValByName("updateTime", new Date(), metaObject);
    }
}
